import api from "../../../utils/api";
import pipe from "../../../assets/js/pipe";
var loginName = localStorage.getItem("_loginName");
export default {
    data(){
    return{
      checked: 'workList',
      activeName: 'second',
      isActive:true,
    //默认选中第一项
      selected:"index",
      tableData:[
          {
            name:"广东省",
            state:"正常",
            report:"-"
          }
      ],
    tableList:[
        {
          name:"湛江海事局",
          state:"正常",
          report:"暂无"
        },
       {
          name:"茂名海事局",
          state:"正常",
          report:"暂无"
        },
        {
          name:"惠州海事局",
          state:"正常",
          report:"暂无"
        },
        {
          name:"珠海海事局",
          state:"正常",
          report:"暂无"
        },
        {
          name:"东莞海事局",
          state:"正常",
          report:"暂无"
        }
    ],
    zhanjiangList:[
        {
          name:"海湾大桥雷达站",
          state:"正常",
          report:"巡检报告"
        },
        {
          name:"洲岛雷达站",
          state:"正常",
          report:"巡检报告"
        },
        {
          name:"山狗吼雷达站",
          state:"正常",
          report:"巡检报告"
        },
        {
          name:"三塘角雷达站",
          state:"正常",
          report:"巡检报告"
        }
    ],
    // 获取row的key值
    getRowKeys(row) {
      return row.id;
    },
      // 要展开的行，数值的元素是row的key值
      expands: [],
      dialogFormVisible:false,//知识库树形dialog
      formLabelWidth:'80',
      query1:'全部',
      query2:'全部',
      query3:'全部',
      query4:'全部',
      //知识档案列表（查询）
      Knowledgepage:1,
      Knowledgerows:10,
      knowledgeForm:{ //查询字段
        tasksn:"",
        startDate:"",
        endDate:"",
        taskTypeResult:[],//任务类型
        MarineBorad:[],//海事局
        radarStation:[],//雷达站
      },
      searchList:[],//查询列表
      selectTreeId:0,//节点id
      selectTreeText:'',//节点text
      //文件类型
      manageList: {
        keywords:''
      },
      //知识库列表
      defaultProps: {
        children: 'children',
        label: 'text'
      },
      knowledgeFileName:[],
      knowledgeFileId:[],
      searchResult:[],//知识库搜索结果
    }
  },
  mounted() {
    // 在这里你想初始化的时候展开哪一行都可以了
    this.expands.push(this.tableList[1].id);
    this.getFileList();
    this.findTaskType();
    this.selectMarineBorad();
  },
  methods:{
    handleToggleDrawer() {
      this.$refs.drawerLayout.toggle();
    },
    toIndex(){
      this.$router.push('/index');
    },
    //档案查询列表
    async getFileList(){
      //页码 条数 海事局编号 雷达站编号 任务序列号 任务类型 开始日期 结束日期
      let data = {
        params:'page='+this.Knowledgepage+"&rows="+this.Knowledgerows+'&marineBoardCode='+this.query2+
        '&taskType='+this.query1+"&radarStationCode="+this.query3+
        "&tasksn="+this.knowledgeForm.tasksn+"&startDate="+this.knowledgeForm.startDate+"&endDate="+this.knowledgeForm.endDate
      }
      const res = await this.$axios._post(api.archivesFind,data);
      var searchResult = document.getElementsByClassName("searchResult")[0];
      var searchCollapse = document.getElementsByClassName("searchCollapse")[0];
      if(res.data.success){
        this.searchList = res.data.data;
        if(res.data.total==0){
          searchResult.innerHTML = '暂无数据';
          searchCollapse.style.display = '';
        }
        var result = this.searchList;
        for(let i=0;i<result.length;i++){
          result[i].createTime = pipe.format(result[i].createTime);
          result[i].jobDate = pipe.format(result[i].jobDate);
          if( result[i].reportType == 'WEIXIU_REPORT'){
            result[i].reportName = '维修报告'
          }else if( result[i].reportType == 'WEIHU_REPORT'){
            result[i].reportName = '维护报告'
          }else if(result[i].reportType == 'YINGJI_REPORT'){
            result[i].reportName = '应急报告'
          }else{
            result[i].reportName = '巡检报告'
          }
        }
      }
    },
   //任务类型
    findTaskType:async function(){
      let data = {
          params:"cateCode=TASK_TYPE"
      }
      const res = await this.$axios._post(api.findTaskMsgList,data);
      if(res.data.success){
        this.knowledgeForm.taskTypeResult = res.data.data;
      }
    },
    //选择海事局
    async selectMarineBorad(){
      let data = {
        params:"orgTypeCode=HAI_SHI"
      }
      const res = await this.$axios._post(api.findOrg,data);
      if(res.data.success){
        this.knowledgeForm.MarineBorad = res.data.data;
      }
    },
    //选择海事局  change  选中的value
    selectMarine(e){
      this.marineBoardCode = e;
      this.selectRadarStation();
    },
    //选择雷达站
    async selectRadarStation(){
      let data = {
        //海事局code
        params:"orgCode="+this.marineBoardCode
      }
      const res = await this.$axios._post(api.findLeida,data);
      if(res.data.success){
         this.knowledgeForm.radarStation = res.data.data;
      }
    },
    //输入关键字 点击搜索知识库
    async searchContent(){
      let data = {
        params:"searchKey="+this.manageList.keywords
      }
      const res = await this.$axios._post(api.resachKnowledge,data);
      if(res.data.success){
        window.console.log(res);
        this.searchResult = res.data.data;
        
      }
    }
  }
}